<?php
header("Content-Type: text/html; charset=UTF-8");
header("Access-Control-Allow-Origin: *"); // 允许所有域名访问
header("Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS");
header("Access-Control-Allow-Headers: Content-Type, Authorization");
header("Access-Control-Allow-Credentials: true"); // 如果需要发送cookies或HTTP认证信息

$path = "./file.js";
// $jsonfile = './test/file.json';
//$jsonfile = '../../../shop10/file.json';

if(@$_GET['r'] == 1){
	$command = 'node '.$path.' read';
	exec($command);
}else{
	$jsonData = file_get_contents('php://input');
	print_r($jsonData);
	file_put_contents($jsonfile,$jsonData);
	$command = 'node '.$path.' write';
	exec($command);
}
?>
